package com.jerry.reflect;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 * Created by Shirly on 2016/12/5.
 */
public class test1 {
    public static void main(String[] args) {
        try {
            Class a = Class.forName("com.jerry.reflect.Students");
            Class b = Students.class;
            Students  s = new Students();
            Class c = s.getClass();
            Object student = a.newInstance();
            Field[] fields = a.getDeclaredFields();
            StringBuffer sb = new StringBuffer();
            sb.append(Modifier.toString(a.getModifiers())+" class "+a.getSimpleName()+"{\n");
            for(Field f :fields){
                sb.append(Modifier.toString(f.getModifiers())+" "+ f.getType().getSimpleName());
                sb.append(" "+f.getName()+";\n");
            }
            sb.append("}");
            System.out.println(sb.toString());


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
